package com.cyanz.dao;

import com.cyanz.entity.Student;

import java.util.List;
import java.util.Map;

/**
 * @author Scyanz
 * @description
 * @date 2020/10/10 15:28
 */
public class StudentProvider {
    public String addBatch(Map<String, List<Student>> map) {
        String sql="insert into tb_student (stu_Name,stu_Age,stu_Password) values";
        StringBuilder sb = new StringBuilder();
        sb.append(sql);
        List<Student> list = map.get("list");
        for (int i = 0; i < list.size(); i++) {
            sb.append("(#{list["+i+"].stuName},#{list["+i+"].stuAge},#{list["+i+"].stuPassword})");
            if (i<list.size()-1){
                sb.append(",");
            }
        }
        System.out.println(sb.toString());
        return sb.toString();
    }
}
